let fileIconData = [
	{
		typeName:"3d",
		types:"glb",
		typeIcon:"/static/file_icons/icon_list_3d.png",
	},
	{
		typeName:"cad",
		types:"dwg dxf svg",
		typeIcon:"/static/file_icons/icon_list_cad.png",
	},
	{
		typeName:"excel",
		types:"xls xlsx",
		typeIcon:"/static/file_icons/icon_list_excel.png",
	},
	{
		typeName:"pdf",
		types:"pdf",
		typeIcon:"/static/file_icons/icon_list_pdf.png",
	},
	{
		typeName:"photo",
		types:"jpg jpeg png",
		typeIcon:"/static/file_icons/icon_list_photo.png",
	},
	{
		typeName:"ppt",
		types:"ppt pptx",
		typeIcon:"/static/file_icons/icon_list_ppt.png",
	},
	{
		typeName:"text",
		types:"txt",
		typeIcon:"/static/file_icons/icon_list_text.png",
	},
	{
		typeName:"video",
		types:"mp4 rmvb avi",
		typeIcon:"/static/file_icons/icon_list_video.png",
	},
	{
		typeName:"zip",
		types:"zip rar 7p",
		typeIcon:"/static/file_icons/icon_list_zip.png",
	},
]

function getType(file) {
	var filename = file;
	var index1 = filename.lastIndexOf(".");
	var index2 = filename.length;
	var type = filename.substring(index1+1, index2);
	return type;
}

function getTypeIconByFile(file) {
	var type = getType(file);
	for(let i = 0 ; i < fileIconData.length; i++) {
		if(fileIconData[i].types.indexOf(type) != -1 )
			return fileIconData[i].typeIcon;
	}
	return "/static/file_icons/icon_other.png"
}

export default {getType ,getTypeIconByFile};
